package com.talos.ums.enums;

import java.util.Objects;

public enum AppVersionTypeEnum {

    ipad("ipad", "ipad"),
    ios("ios", "ios"),
    android("android","安卓");

    private final String code;
    private final String msg;

    AppVersionTypeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * 枚举类型转换，由于构造函数获取了枚举的子类enums，让遍历更加高效快捷
     * @param code 数据库中存储的自定义code属性
     * @return code对应的枚举类
     */
    public static AppVersionTypeEnum locateEnum(String code) {
        for(AppVersionTypeEnum status : AppVersionTypeEnum.values()) {
            if(Objects.equals( status.getCode() , code)) {
                return status;
            }
        }
        return null;
    }

}
